package com.springboot.project.common.service.impl;
import com.springboot.config.generator.GenUtils;
import com.springboot.project.common.dao.GeneratorDao;
import com.springboot.project.common.service.GeneratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipOutputStream;


@Service
public class GeneratorServiceImpl implements GeneratorService  {

	@Resource
	GeneratorDao generatorDao;

	@Override
	public List<Map<String, Object>> list() {
		List<Map<String, Object>> list = generatorDao.list();
		return list;
	}

	@Override
	public void generatorCode(String tableName) {
		//查询表信息
		Map<String, String> table = generatorDao.get(tableName);
		//查询列信息
		List<Map<String, String>> columns = generatorDao.listColumns(tableName);
		//生成代码
		GenUtils.generatorCode(table, columns);
	}
}
